/**
 * Created by dqw on 2015/12/30.
 */

//列表开始
var dtGridColumns = [
    {
        id: 'delFlag',
        type: 'int',
        hideQuery:true,
        'export':false,
        hideQueryType:'eq',
        hideQueryValue:1,
        hide:true

    },
    {
        id: 'user.realName',
        title: '姓名',
        type: 'string',
        headerClass: 'text-center width-200',
        columnClass: 'text-left width-200',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'lk'
    },
    {
        id: 'user.mobile',
        title: '手机号',
        type: 'string',
        headerClass: 'text-center width-200',
        columnClass: 'text-left width-200',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'lk'
    },
    {
        id: 'mmmId',
        title: '第三方资金账户',
        type: 'string',
        headerClass: 'text-center width-200',
        columnClass: 'text-left width-200',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'lk'
    },
    {
        id: 'total',
        title: '账户总额(元)',
        type: 'number',
        headerClass: 'text-center width-200',
        columnClass: 'text-left width-200',
        fastSort: false
    },
    {
        id: 'available',
        title: '可用金额(元)',
        type: 'number',
        headerClass: 'text-center width-200',
        columnClass: 'text-left width-200',
        fastSort: false
    },
    {
        id: 'freeze',
        title: '冻结金额(元)',
        type: 'number',
        headerClass: 'text-center width-200',
        columnClass: 'text-left width-200',
        fastSort: false
    },
    {
        id: 'createTime',
        title: '添加时间',
        type: 'date',
        format: 'yyyy-MM-dd hh:mm:ss',
        headerClass: 'text-center width-200',
        columnClass: 'text-left width-200',
        fastSort: false,
        fastQuery: true,
        fastQueryType: 'range'
    },
];

var dtGridOption = {
    lang: 'zh-cn',
    ajaxLoad: true,
    loadURL: ncGlobal.adminRoot + 'account/json/list',
    exportURL: ncGlobal.adminRoot + 'account/json/export',
    exportFileName: '平台账户列表',
    columns: dtGridColumns,
    gridContainer: 'dtGridContainer',
    toolbarContainer: 'dtGridToolBarContainer',
    tools: 'refresh|faseQuery|export[excel]',
    pageSize: 10,
    pageSizeLimit: [10, 20, 50],
    ncColumnsType: {BigDecimal:["total","available","freeze"],int:["type"],Timestamp: ["createTime"]}
};

var grid = $.fn.DtGrid.init(dtGridOption);
grid.fastQueryParameters = new Object();
grid.fastQueryParameters['eq_delFlag'] = 1;
grid.fastQueryParameters[ 'eq_id'] = 1;

//排序
grid.sortParameter.columnId = ['desc_createTime'];
//列表结束

//操作处理开始
var OperateHandle = function () {

    function _bindEvent() {
        //模糊搜索
        $('#customSearch').click(function () {
            grid.fastQueryParameters = new Object();
            grid.fastQueryParameters['eq_delFlag'] = 1;
            grid.fastQueryParameters['lk_user.mobile_or_like_user.real_name'] = $('#keyword').val();
            grid.pager.startRecord = 0;
            grid.pager.nowPage = 1;
            grid.pager.recordCount = -1;
            grid.pager.pageCount = -1;
            grid.refresh(true);
        });
    }
    //外部可调用
    return {
        bindEvent: _bindEvent,
    }
}();
//操作处理结束

$(function () {
    //加载列表
    grid.load();
    //页面绑定事件
    OperateHandle.bindEvent();
});